package com.hello.system.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.hello.common.log.annotation.Log;
import com.hello.common.log.enums.BusinessType;
import com.hello.common.security.annotation.RequiresPermissions;
import com.hello.system.domain.ReportGenerationLog;
import com.hello.system.service.IReportGenerationLogService;
import com.hello.common.core.web.controller.BaseController;
import com.hello.common.core.web.domain.AjaxResult;
import com.hello.common.core.utils.poi.ExcelUtil;
import com.hello.common.core.web.page.TableDataInfo;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;

/**
 * 报生成记录Controller
 * 
 * @author hello
 * @date 2025-09-09
 */
@Slf4j
@RestController
@RequiredArgsConstructor
@RequestMapping("/reportGenerationLog")
public class ReportGenerationLogController extends BaseController
{
    private final IReportGenerationLogService reportGenerationLogService;

    /**
     * 查询报生成记录列表
     */
    @RequiresPermissions("system:reportGenerationLog:list")
    @GetMapping("/list")
    public TableDataInfo list(ReportGenerationLog reportGenerationLog)
    {
        startPage();
        List<ReportGenerationLog> list = reportGenerationLogService.selectReportGenerationLogList(reportGenerationLog);
        return getDataTable(list);
    }

    /**
     * 导出报生成记录列表
     */
    @RequiresPermissions("system:reportGenerationLog:export")
    @Log(title = "报生成记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ReportGenerationLog reportGenerationLog)
    {
        List<ReportGenerationLog> list = reportGenerationLogService.selectReportGenerationLogList(reportGenerationLog);
        ExcelUtil<ReportGenerationLog> util = new ExcelUtil<ReportGenerationLog>(ReportGenerationLog.class);
        util.exportExcel(response, list, "报生成记录数据");
    }

    /**
     * 获取报生成记录详细信息
     */
    @RequiresPermissions("system:reportGenerationLog:query")
    @GetMapping(value = "/{generationId}")
    public AjaxResult getInfo(@PathVariable("generationId") Long generationId)
    {
        return success(reportGenerationLogService.selectReportGenerationLogByGenerationId(generationId));
    }

    /**
     * 新增报生成记录
     */
    @RequiresPermissions("system:reportGenerationLog:add")
    @Log(title = "报生成记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ReportGenerationLog reportGenerationLog)
    {
        return toAjax(reportGenerationLogService.insertReportGenerationLog(reportGenerationLog));
    }

    /**
     * 修改报生成记录
     */
    @RequiresPermissions("system:reportGenerationLog:edit")
    @Log(title = "报生成记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ReportGenerationLog reportGenerationLog)
    {
        return toAjax(reportGenerationLogService.updateReportGenerationLog(reportGenerationLog));
    }

    /**
     * 删除报生成记录
     */
    @RequiresPermissions("system:reportGenerationLog:remove")
    @Log(title = "报生成记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{generationIds}")
    public AjaxResult remove(@PathVariable Long[] generationIds)
    {
        return toAjax(reportGenerationLogService.deleteReportGenerationLogByGenerationIds(generationIds));
    }
}
